# coding=utf-8
import requests
import xlwt


def test_data():
    try:
        url = "https://vip.cric.com/cric2019-core-app/marketmonitoring/commercialhouseing/tradesupply/dataperspective"
        cookie = {'Hm_lpvt_8326cb81b7a16c53e132fd742bc1a3d3':'1642399468','Hm_lvt_8326cb81b7a16c53e132fd742bc1a3d3':'1642392110,1642397721'}
        header = {"content-type":"application/json","authorizationexchange":"07E524AF6BDCB5E300071F57FAEAB994660870F347379107ECB1C7B2E2C89C1099D912A92E062C97748841D7D6CC146C"
                  ,"authorization":"d47133c7-2ef2-402e-96fc-59a7f5d820b4,10503"}
        body = {"regionType": "区域", "homeType": "商品房", "homeTypeHouse": ["车库/车位"], "areaStep": [], "priceStep": [],
                "moneyStep": [], "userGroupId": 0, "rType": [], "conformation": [], "fitment": [],
                "time": "2021年12月--2021年12月", "timeType": "最新完整月", "orderType": 0, "cityCode": "CN-HN-GUANGZHOU",
                "userId": "10503", "cityName": "广州", "moduleCode": "111", "needRingAndYTY": 1, "region": [],
                "plate": [], "circle": [], "customArea": [], "dimType": "time",
                "tableUnit": {"areaUnit": 1, "amountUnit": 3},
                "orderKey": "commercialHousing.tradesupply.transactionArea", "pageNo": 1, "pageSize": 100,
                "systemType": "cric", "osName": "Win10", "browser": "chrome 96.0.4664.45"}
        r1 = requests.post(url, json=body,headers=header,cookies=cookie, timeout=15)
        result = r1.json()
        print(result)
        # workbook = xlwt.Workbook()
        # sheet1 = workbook.add_sheet('data')
        # ll = list(result[0].keys())
        # for i in range(0, len(ll)):
        #     sheet1.write(0, i, ll[i])
        # for j in range(0, len(result)):
        #     m = 0
        #     ls = list(result[j].values())
        #     for k in ls:
        #         sheet1.write(j + 1, m, k)
        #         m += 1
        # workbook.save('cardata.xls')



    except Exception as ex:
        print(111)
        print(ex)


if __name__ == '__main__':
    test_data()
